import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.transaction.annotation.Transactional;

import java.sql.SQLException;
@Transactional
public class DataSource {

    public static void main(String[] args) throws SQLException {

        ApplicationContext context = new ClassPathXmlApplicationContext("classpath:datasource.xml");

        BasicDataSource dataSource = context.getBean("datasource", BasicDataSource.class);
        System.out.println(dataSource.getConnection().toString());


        ComboPooledDataSource comboPooledDataSource = context.getBean("c3p0datasource", ComboPooledDataSource.class);
        System.out.println("c3p0" + comboPooledDataSource.getConnection());

        dataSource = context.getBean("propretiesDatasource", BasicDataSource.class);
        System.out.println(dataSource.getConnection().toString());

    }

}
